package leecode

func setZeros(matrix [][]int) {
	var rowColumn [][]int
	//遍历二维数组 , 找到0所在的行和列
	for row, data := range matrix {
		for column, value := range data {
			if value == 0 {
				//将需要设为0的行和列追加到切片中
				rowColumn = append(rowColumn, []int{row, column})
			}
		}
	}
	for i := 0; i < len(rowColumn); i++ {
		row := rowColumn[i][0]
		column := rowColumn[i][1]
		//行设为0
		for j := 0; j < len(matrix[0]); j++ {
			matrix[row][j] = 0
		}
		//列设为0
		for k := 0; k < len(matrix); k++ {
			matrix[k][column] = 0
		}
	}
}
